package com.gougang.interview;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 16978 on 2017/4/6.
 */
public class QiaoPaiGame extends PokerGame {

    private static final CardBean[] cards = new CardBean[52];
    private static final Map<String, List<CardBean>> team = new HashMap<String, List<CardBean>>();
    /**
     * 洗牌
     */
    public void shuffle() {
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < 4; j++) {
                //初始化一张扑克
                CardBean card = new CardBean();
                card.setNumber(Utils.getPokerNumber(i));
                CardType type = CardType.getType(j);
                card.setType(type);
                card.setScore(Utils.getCardScore(type));


                int num = Utils.getRandom(52);
                while (cards[num] != null) {
                    num = Utils.getRandom(52);
                }

                cards[num] = card;
            }
        }
        for (CardBean c:
             cards) {
            System.out.println(c.getNumber()+c.getType().name() + "\n");
        }
    }

    /**
     * 发牌
     */
    public void deal() {
      List<CardBean> cardBeens = Arrays.asList(cards);
        team.put("east",cardBeens.subList(0,13));
        team.put("west",cardBeens.subList(13,26));
        team.put("south",cardBeens.subList(26,39));
        team.put("north",cardBeens.subList(39,52));
    }

    public int getRound() {
        return 12;
    }

    public List<CardBean> getCards(String point) {
        return team.get(point);
    }


}
